package com.bjpowernode.services;
import com.bjpowernode.beans.Message;
import com.bjpowernode.exception.MyException;
import com.bjpowernode.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;

@Service
public class MessageServicesImp implements MessageServices{


    @Autowired
    MessageMapper messageMapper;


    @Override
    public ArrayList<Message> getAll() {
        return messageMapper.getAll();
    }

    @Override
    public void add(Message message) throws MyException {

        int add = messageMapper.add(message);
        if(add<=0){
            throw new MyException("留言添加失败，没有影响行数");
        }
    }

    @Override
    public void del(int[] id) throws MyException {

        int del = messageMapper.del(id);
        if(del<=0){
            throw new MyException("留言删除失败，没有影响行数");
        }

    }
}
